export default {
	data() {
		return {
			// 字体
			fontZT: [{
					name: 'header',
					value: 'H1',
					checkID: '1',
					icon: 'lsj-icon-format-header-'
				},
				{
					name: 'header',
					value: 'H2',
					checkID: '2',
					icon: 'lsj-icon-format-header-1'
				},
				{
					name: 'header',
					value: 'H3',
					checkID: '3',
					icon: 'lsj-icon-format-header-2'
				},
				{
					name: 'header',
					value: 'H4',
					checkID: '4',
					icon: 'lsj-icon-format-header-3'
				},
				{
					name: 'header',
					value: 'H5',
					checkID: '5',
					icon: 'lsj-icon-formatheader5'
				},
				{
					name: 'header',
					value: 'H6',
					checkID: '6',
					icon: 'lsj-icon-formatheader6'
				},
			],
      // 文字样式
      fontStyle:[
        {
        	name: 'bold',
        	checkID: true,
        	icon: 'doctor-bold'
        },
        {
        	name: 'italic',
        	checkID: true,
        	icon: 'doctor-italic'
        },
        {
        	name: 'underline',
        	checkID: true,
        	icon: 'doctor-underline'
        },
        {
        	name: 'strike',
        	checkID: true,
        	icon: 'doctor-strikethrough'
        }
      ],
			// 格式
			fontGS: [{
					name: 'marginTop',
					value: '20px',
					checkID: '20px',
					icon: 'doctor-align-top'
				},
				{
					name: 'marginBottom',
					value: '20px',
					checkID: '20px',
					icon: 'doctor-align-bottom'
				},
				{
					name: 'align',
					value: 'left',
					checkID: 'left',
					icon: 'doctor-align-left'
				},
				{
					name: 'align',
					value: 'center',
					checkID: 'center',
					icon: 'doctor-align-center'
				},
				{
					name: 'align',
					value: 'right',
					checkID: 'right',
					icon: 'doctor-align-right'
				},
				{
					name: 'align',
					value: 'justify',
					checkID: 'justify',
					icon: 'doctor-align-justify'
				},
				{
					name: 'indent',
					value: '-1',
					checkID: 'indent',
					icon: 'doctor-indent-decrease'
				},
				{
					name: 'indent',
					value: '+1',
					checkID: 'indent',
					icon: 'doctor-indent-increase'
				},
				{
					name: 'direction',
					value: 'rtl',
					checkID: 'rtl',
					icon: 'doctor-duanlaqianzhi'
				},
				{
					name: 'lineHeight',
					value: '2',
					checkID: '2',
					icon: 'doctor-line-height'
				},
				{
					name: 'letterSpacing',
					value: '2em',
					checkID: '2em',
					icon: 'doctor-text-spacing'
				},
				{
					name: 'script',
					value: 'sub',
					checkID: 'sub',
					icon: 'doctor-subscript-2'
				},
				{
					name: 'script',
					value: 'super',
					checkID: 'super',
					icon: 'doctor-superscript-2'
				},
				{
					name: 'list',
					value: 'check',
					checkID: 'check',
					icon: 'doctor-list-view'
				},
				{
					name: 'list',
					value: 'ordered',
					checkID: 'ordered',
					icon: 'doctor-list-ordered'
				},
				{
					name: 'list',
					value: 'bullet',
					checkID: 'bullet',
					icon: 'doctor-list-unordered'
				},
				{
					name: 'insertDivider',
					value: '',
					checkID: true,
					icon: 'doctor-separator',
					customFn: 'tool'
				},
				{
					name: 'removeFormat',
					value: '',
					checkID: true,
					icon: 'doctor-format-clear',
					customFn: 'tool'
				},
				{
					name: 'clear',
					value: '',
					checkID: 'clear',
					icon: 'doctor-lajitong-copy',
					customFn: 'tool'
				},
			],
			statusObj: {},
			fontsize: 16,
		}
	},
	created() {
		// 监听光标所在位置状态
		this.edit.$on('edit:statuschange', this.statuschange);
	},
	methods: {
		// 根据光标位置更新字号
		statuschange(e) {
			this.statusObj = e.detail;
			if (this.statusObj.hasOwnProperty('fontSize')) {
				this.fontsize = parseInt(this.statusObj['fontSize']);
			}
			else {
				this.fontsize = 16;
			}
		},
		// 字号按钮点击
		fontSetSize(up = false) {
			if (this.fontsize <= 10 || this.fontsize >= 50) {
				return;
			}
			let font = up ? this.fontsize + 1 : this.fontsize - 1;
			return this.fontSliderChange({detail: {value: font}});
		},
		// 字号滑动条
		fontSliderChange({
			detail
		}) {
			this.fontsize = detail.value;
			this.edit.format('fontSize', detail.value + 'px');
		},
		// 列表点击事件
		fontCell_Click(item) {
			this.edit[item.customFn ? item.customFn : 'format'](item.name, item.value);
		},
	}
}
